<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>主页</title>
    <script src="../../static/js/jquery.min.js"></script>
    <link rel="stylesheet" href="../../static/css/reset.css">
    <link rel="stylesheet" href="../../static/css/common.css">
    <link rel="stylesheet" href="../../static/css/home.css">
</head>
<body>
    <div class="box" >
        <header class="header">
            <h1>异常用电行为查询系统</h1>
        </header>
        <section class="home-content">
            <h2>导入文件</h2>
            <form action="" onsubmit="return false">
                <input type="file" name="file" id="file" class="home-file"  style="color:rgba(0,0,0,.25)"/>
                <input type="submit" class="home-button" value="运行"/>
            </form>
        </section>
        <footer class="footer">
            Copyright © 2021 异常用电行为查询系统
        </footer>
    </div>
    <script>
        $(function(){
            $(".home-button").click(function () {
                var formData=new FormData();
                formData.append("file",$("#file")[0].files[0]);
                formData.append("type","voltage");
                $.ajax({
                    url:'../../importExcel',
                    type:'post',
                    data:formData,
                    contentType:false,
                    processData:false,
                    success:function (res) {
                        var temp=JSON.parse(res);
                        if(temp.code=="200"){
                            $(location).attr("href","../success/index.html");
                        }else {
                            alert(temp.msg);
                        }
                    }
                })
                //$(location).attr("href","../success/index.html");
            })
        })

    </script>
</body>
</html>